package com.example.mystoryapp2.adapter

import android.view.View
import androidx.appcompat.widget.AppCompatTextView
import com.example.mystoryapp2.R
import com.example.mystoryapp2.domain.RecordStatic
import com.example.mystoryapp2.ui.base.BaseListAdapter
import com.example.mystoryapp2.ui.base.BaseViewHolder
import java.util.ArrayList

class RecordsListAdapter(private val list: ArrayList<RecordStatic>) :
    BaseListAdapter<RecordStatic,RecordsListAdapter.RecordListViewHolder>(list) {
    class RecordListViewHolder(item: View) : BaseViewHolder(item) {
        val tvName: AppCompatTextView = item.findViewById(R.id.tvPageName)
        val tvViewCount: AppCompatTextView = item.findViewById(R.id.tvViewCount)
        override fun getViewList(): List<View> {
            val arrayList = ArrayList<View>()
            arrayList.add(tvName)
            return arrayList
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.item_static_list_layout
    }

    override fun createViewHolder(itemView: View): RecordListViewHolder {
        return  RecordListViewHolder(itemView)
    }

    override fun onBaseBindViewHolder(holder: RecordListViewHolder, position: Int) {
        val static = list[position]
        holder.tvName.text = static.page?.pageName
        holder.tvViewCount.text = static.count.toString()
    }
}